package cn.bdqn.applysystem.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import cn.bdqn.applysystem.dao.StudentMapper;
import cn.bdqn.applysystem.entity.Student;
import cn.bdqn.applysystem.service.StudentService;

@Service("studentServiceImpl")
public class StudentServiceImpl implements StudentService {


	@Autowired
	@Qualifier("studentMapper")
	StudentMapper studentMapper;
	
	/**
	 * 添加学生信息
	 * */
	@Transactional(isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED)
	public int SaveStudent(Student student){
		int num = studentMapper.insertStudent(student);
		return num;
	}

	/**
	 * 根据咨询老师ID查询学生信息
	 * */
	@Override
	@Transactional(isolation=Isolation.READ_COMMITTED,propagation=Propagation.SUPPORTS)
	public List<Student> findStudentByCounselor() {
		return studentMapper.selectStudentListByCounselorId();
	}

	/**
	 * 根据id查询学生信息
	 * */
	@Override
	@Transactional(isolation=Isolation.READ_COMMITTED,propagation=Propagation.SUPPORTS)
	public Student findStudentById(int id) {
		return studentMapper.selectStudentById(id);
	}

	/**
	 * 根据id修改学生信息
	 * */
	@Override
	@Transactional(isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED)
	public int updateStudent(Student student) {
		return studentMapper.updateStudent(student);
	}

	@Override
	@Transactional(isolation=Isolation.READ_COMMITTED,propagation=Propagation.SUPPORTS)
	public List<Student> findStudentListByGradeId(Integer gradeId) {
		return studentMapper.selectStudentListByGradeId(gradeId);
	}

}
